package com.microservice.skeleton.upms.service.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.microservice.skeleton.upms.entity.RcUser;
import com.microservice.skeleton.upms.mapper.RcUserMapper;
import com.microservice.skeleton.upms.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;

import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Mr.Yangxiufeng
 * Date: 2018-05-10
 * Time: 19:57
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private RcUserMapper userMapper;

    @Autowired
    private MongoTemplate mongoTemplate;

    @Autowired
    private ObjectMapper objectMapper;

    @Override
    public RcUser findByUsername(String username) {
        List<RcUser> all = mongoTemplate.findAll(RcUser.class);
        return all.get(0);
    }

    @Override
    public void add(RcUser user) {
        user.setUpdateTime(new Date());
        mongoTemplate.insert(user);
    }
}
